#!/bin/bash
#
# Converts all data files in a directory to unix format
# i.e. makes the newline characters \n instead of \r etc.. 
# Places all converted files into import directory. 
#
#
#

mkdir -p import
rm -f import/*
TEMP=$1/tmp

for f in $1/*; do
#	if [[ $f == *.txt ]]; then
#		OUTPUT="${f%.txt}_u.txt"
#	else
		OUTPUT="$f"_u
#	fi
	touch $OUTPUT
	tr '\r' '\n' < $f > $TEMP
	tr '\015' '\012' < $TEMP > $OUTPUT	
	mv $OUTPUT import
done
rm $TEMP

cd import
for fu in *; do
	mv $fu ${fu%_u}
done


exit 0
